Repository navigation
fix(lint): the flow and hook publish doors stop requiring a null guard on the current row's created_at and updated_at in an ordering comparison - #33434
Conversation
…njected system columns, as os build does Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…injected system column as os build does Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…n a flow or hook condition as os build does Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
📓 Docs Drift CheckThis PR changes 1 package(s): 39 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 00d5640e2921ea1a3d6f8dedcd54af232caa5f8b && git checkout 00d5640e2921ea1a3d6f8dedcd54af232caa5f8b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4c32b9694b7b248646b2053b6eafea2cc212693b 4593c1d0df206e3833da00e4278177b6f2cf634a && git checkout -B drift-repro 4c32b9694b7b248646b2053b6eafea2cc212693b && git merge --no-ff 4593c1d0df206e3833da00e4278177b6f2cf634a
node scripts/docs-audit/affected-docs.mjs --json 4c32b9694b7b248646b2053b6eafea2cc212693b
|
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag Contract reviewServed-tier: PR #33434 for card #33246, on the declaration face. Read: the card body and its seven comments (6879098956, 6879740792, 6880234097, 6880862710, 6883467822, 6884094895, 6884116702), the PR body, its three-path file list, the net diff against Check-runs on the head, read on 2026-11-14: 63 runs: 22 success, 11 skipped, 30 in progress, none failed. One must-fix (F1), two should-fix (F2, F3), two nits (N1, N2). ① Derived judgments
F1, must-fix. The strip also empties the type index of the injected columns at every runtime door, so the hook, flow, action and object doors stop giving type verdicts they gave on
② Semver level
N1, nit. ③ Boundary flags
F2, should-fix, escalated to the seat. The door newly accepts five columns the dev measured NULL on a stored row, and the follow-up will refuse them again.
F3, should-fix. No committed case reads the object as the registry serves it at the real door.
N2, nit. The PARITY case on Implemented-by: VERDICT: FAIL |
…ps out of its nullable index, and keeps every served type Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…dering over the stamped timestamps and refuse one over owner_id Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…he five it still judges Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag Contract reviewServed-tier: Round 2 on PR #33434 for card #33246, on the declaration face. Round 1 is record 6884221427 at Check-runs on the head, read on 2026-11-14: 70 runs: 57 success, 13 skipped, none failed, none pending. Every One must-fix (M1), one should-fix (S1), three nits (N3, N4, N5). Round-1 findings at this head:
① Derived judgments
M1, must-fix. At the flow door a
② Semver level
③ Boundary flags
S1, should-fix, escalated to the seat. "Never null" holds for a stored row; a
N3, nit. N4, nit. The PR body and the report count seven cases in the lint describe (and "1 of 7", "3 of 7" red under ablation). The describe at this head holds six N5, nit. The CONTROL case's title says no stamp is behind an author's own Implemented-by: VERDICT: FAIL |
…tamped timestamps, and not on a beforeInsert hook The null-guard skip at a runtime publish door now applies to an operand of `<`, `<=`, `>` or `>=` only. Arithmetic over created_at / updated_at keeps its verdict, so a flow's `record.created_at + 1 > 0` stays refused as on main. A hook whose events include beforeInsert can run before the platform's stamp, so it keeps the verdict too. The changeset is renamed for the mechanism and names the six injected columns still judged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…nd the stamped-column index locals Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag Contract reviewServed-tier: Round 3 on PR #33434 for card #33246, on the declaration face. Round 1 is record 6884221427 at Check-runs on the head, read on 2026-11-14: 69 runs in the latest attempt: 55 success, 13 skipped, 1 in progress, none failed.
One must-fix (M2), one should-fix (S2), one nit (N6). The verdict is FAIL on M2 alone; it does not rest on the shard still running. Round-2 findings at this head:
① Derived judgments
M2, must-fix. An unguarded ordering over
② Semver level
③ Boundary flags
S2, should-fix, escalated to the seat. A hook on a read event with the same ordering now publishes; it rejects every read.
N6, nit. Two texts still describe round 2's mechanism. The comment above the lint describe says the door's null-guard gate "does not judge" the two columns, "as Implemented-by: VERDICT: FAIL |
…mp, and only on a hook whose every event reads a stamped row An ordering over previous.created_at / previous.updated_at keeps its verdict: an insert binds previous to null. A hook on beforeFind or afterFind carries no record, so it keeps the verdict too; the skip now applies only when every event is afterInsert, beforeUpdate, afterUpdate, beforeDelete or afterDelete. The changeset and the test docblocks state this mechanism. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag Contract reviewServed-tier: Round 4 on PR #33434 for card #33246, on the declaration face. Rounds 1 to 3 were FAIL: records 6884221427 ( Check-runs on the head, read on 2026-11-14: 70 runs in the latest listing: 56 success, 13 skipped, 1 in progress, none failed.
No must-fix, no should-fix, one nit (N7, no change owed). The verdict is PASS. Round-3 findings at this head:
① Derived judgments
N7, nit, no change owed. The warrant "a read of the current row after the stamp is never ② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS Seat note: the read-event gate card the record escalates is #33529 (p3, spec lane), filed before this record was posted. |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag ACCEPT · PR #33434 (#33246) · head
|
…ormula cycle an object extension adds (objectstack-ai#33442) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XH2axL4s7aEsVfT4UcgVK1P)_ Fixes objectstack-ai#33153 Clause-②: no (narrowing) — `os build`, `os validate`, `os lint` and the runtime `object_extension` publish door (Studio, `PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors) now refuse one shape an object extension could carry before: a `formula` field an extension adds that sits on a cycle of formulas (it reads itself, two added formulas read each other, or the cycle closes through a formula the target declares). No exported type or signature changes. Measured first-party exposure: 0 `objectExtensions` entries add a `formula` field (`examples/app-showcase` one entry, a `select`, a `url` and a `number` field; `packages/plugins/plugin-auth` one, a `secret` field; HotCRM `origin/main` ac4dd3d has no `objectExtensions` in code), so nothing first-party is newly refused. Metadata-protocol: narrowed Skills-docs: none owed — this PR edits `content/docs/deployment/validating-metadata.mdx` (the object extension paragraph names the cycle check); `skills/objectstack-formula` and `skills/objectstack-data` teach formula fields and `defineObjectExtension({ extend, fields })` without saying an extension is exempt from the cycle check, so the build and the door now give the verdict the object's own formulas already get. Precedent followed: objectstack-ai#33216/objectstack-ai#33217 (PR objectstack-ai#33398), which widened the same extension walk and declared the same `no (narrowing)` / `narrowed` pair. ## 维护者速读 - **改了什么**:对象扩展(`objectExtensions` / Studio 发布的 `object_extension`)新增的公式字段,如果引用自己,或两个互相引用,或经由对象自身声明的公式绕回来,现在在 `os build` 和运行时发布口都会被拒(规则 id `expression-invalid`,和对象自身公式循环同一句提示),位置为 `object '对象' · objectExtensions[0] · field '字段' expression`。 - **为什么改**:引擎按依赖顺序计算公式,循环里的公式永远不会被计算、每行都读到空值。此前循环检查只看对象自身声明的公式,扩展加的循环在两个入口都放行,要到读记录时才暴露。 - **风险与回滚**:收窄;第一方实测 0 处扩展新增公式字段,无既有元数据被新拒。对象自身公式循环的结论与位置不变;对象声明的公式与扩展公式构成的循环,声明那一侧仍报在对象上、只报一次;发布口不会把目标对象自身已有的循环算到扩展这次写入上。草稿保存不受影响。回滚即 revert。 - **先看**:`packages/lint/src/validate-expressions.ts`(扩展遍历末尾新增的一次 `formulaCycleIssues` 调用)、`packages/lint/src/formula-cycle-issues.ts`(`extensionFormulaLoci` 与 map 形式的 `report`)、`packages/lint/src/runtime-gate.object-formula-cycle.test.ts`。 - **两分钟验证**:`pnpm --filter @objectstack/lint exec vitest run src/runtime-gate.object-formula-cycle.test.ts`,预期 16 条全过:扩展自引用、互相引用、经声明公式绕回的循环在 build 与发布口都被拒且位置一致,链式公式和读对象公式的扩展公式通过;发布口按写入条目自身的定义判定同名字段(含与其他包同优先级或被更高优先级覆盖的情形,build 此时放行,后续卡 objectstack-ai#33494)。 - **需要你做的**:无,席位落地。 ## What changes **`packages/lint/src/validate-expressions.ts` (the extension walk only; the gate-setup region objectstack-ai#33246 edits is untouched).** After each target's entries are judged, the walk runs the formula-cycle pass (objectstack-ai#33100's `formulaCycleIssues`) over the `fieldDefs` it already builds for that target: the target as served (its declared fields with every kept entry's fields folded in through `objectsAsServed`, a tie between two packages left out), its declared fields and injected columns behind it; for a target the stack does not declare, the entries' own fields. No second fold. Each cycle member an entry adds gets a finding located at that entry, and in the build a member the authored target declares is left to the object walk, so a cycle closing through a declared formula keeps that member's location at the object and names it once. On the door's one pass the object walk does not run and the written entry is folded over the target as served before the write, so every name the entry adds is served from the entry's own record and none is left out, a name the target already serves included (review round 1). **`packages/lint/src/formula-cycle-issues.ts`.** `formulaCycleIssues`' `report` also takes a map from field name to location. The new `extensionFormulaLoci(target, entries, left)` builds it: each name an entry adds, located `object 'T' · objectExtensions[i] · field 'F' expression` (the location the field-formula pass gives the same field), a name two entries add located at the later entry in fold order (the definition the registry serves), the caller's `left` names left out (the authored target's declared names in the build, none at the door). Kept in this module so the walk gains no new receiver for the objectstack-ai#5017 key scan. **Door.** `validateStackExpressions` is already on the `object_extension` door (objectstack-ai#33072), so the roster and its pins do not move. The door's one pass reads only the written entry, and only names the entry adds are reported members there, so a cycle the target or a sibling package already carries, and a formula that only reads a cycle, are not charged to the extension write. **`packages/spec/src/migrations/entries/semantic/18.object-extension-formula-cycle-refused.ts`**: the ADR-0087 D3 entry, its one exception stated (in `os build` on a declared target, a field two packages add at the priority that decides it is not judged; the door judges the written entry's own definition, see objectstack-ai#33494). No D2 conversion: which read breaks the cycle is a fact only the author holds. **`content/docs/deployment/validating-metadata.mdx`**: the object extension paragraph names the cycle check, its location in the build, and the door's reading of a name the target already serves. **`.changeset/33153-extension-formula-cycle.md`**: `@objectstack/lint` minor and `@objectstack/spec` minor, both declaration lines, a BREAKING banner (Before / Now / Unchanged / Fix) and `adr-0087: registered object-extension-formula-cycle-refused`. ## Why The engine computes an object's formulas, an extension's included, in dependency order; a formula on a cycle has no order, is never evaluated and reads null on every row. The cycle check named the object's declared formulas only, so the card's probe (an extension adding `a__c = record.a__c`, or `a__c` and `b__c` reading each other) got 0 findings at both the build and the door. ## Tests 1. **`packages/lint/src/runtime-gate.object-formula-cycle.test.ts`**, new top-level describe `objectstack-ai#33153` (11 cases) in the objectstack-ai#33100 harness file, at the real gate (`runRuntimeAuthoringRules` with `type: 'object_extension'`) and the build (`runAuthoringRules('build', …)`): - LIT: an extension formula reading itself is refused at the door at the entry, in the engine's sentence (`formulaCycleMessage`); the build's finding equals the door's (where and message). - LIT: two extension formulas reading each other are refused on each, door and build equal. - LIT: a cycle closing through a declared formula: the door refuses the added member at the entry; the build names the declared member at the object (its objectstack-ai#33100 location) and the added member at the entry, once each. - A cycle across two packages' extensions is named at each entry (`packages[j].manifest.objectExtensions[0]`). - LIT (review round 1, shape a): an extension re-declaring a field the target declares as a formula reading itself is refused at the door at the entry; the build names it once, at the object. - LIT (review round 1, shape b): an entry adding, as a self-reading formula, a name a sibling package's published extension already serves is refused at the door at the entry; the build over both packages (sibling priority 100, written entry 300) refuses it at the later entry. - Review round 2: the door judges the written entry's own definition whatever a sibling package's priority. A tie (both 200) and an outranked entry (sibling 300, written 200) are each refused at the door at the entry, while the build lets both through (it drops the tied name on a declared target and serves the outranking sibling's definition). The pin names follow-up objectstack-ai#33494, which makes the door read the build's winner. - A sibling package's stored cycle, and an extension formula that only reads it, are not charged to the extension write. - An extension of an object the door does not carry is judged on its own fields. - The target's own stored cycle is not the extension write's to answer for (the differential). - CONTROL: an extension formula over a declared formula, and a chain inside the extension, are clean at both. 2. **`packages/runtime/src/domains/meta-object-extension-item.test.ts`**, new describe `[objectstack-ai#33153]` (3 cases) through the real `saveMetaItem` + `publishMetaItem`: a self-reading formula and a two-formula cycle each get 422 `INVALID_METADATA` with the build's rule id, `where` and `path` on each member, the field is not served and the row stays a draft; a chain publishes and is served. **Red at base:** the round-0 head tests over the base sources (`git restore --source=fc283d6d` of the two lint files): 5 of 12 red (the file then held 12 cases), every LIT plus the sibling and undeclared-target cases; controls and the differential green. Restored with `git checkout HEAD --`, `git status --porcelain` empty. **Ablations** (one-shot, through `node scripts/ablation-replace.mjs` on the committed head; the tool's restore verdict each time: blob equals HEAD, `git diff HEAD` empty): - A1, the report scoping in `formulaCycleIssues` (`!report.has(field)` dropped, so every served member is reported): 5 of 12 red (round 0), including the differential case (the target's own cycle charged to the extension write) and the declared-member case (named twice). Lint tests read `src/`. - A3 (review round 1), the door guard (`base && !extensionWrite` back to `base`, the round-0 reading): 2 of 15 red, exactly shapes a and b; and the build-side exclusion (`ownNames` emptied in the build too, behind an opaque `globalThis` marker): 1 red, shape a's build assertion (the member named twice). Both restored by the tool's verdict. - A4 (review round 2), the same door-guard mutation at `bfa139ba`: 3 of 16 red, shapes a and b and the tie/outranked pin; restored by the tool's verdict. - A2, the extension loci (entries read as none, behind an opaque `globalThis` marker), for the runtime pins that read lint through `dist/`: `pnpm --filter @objectstack/lint build`, `ablation-dist-preflight` found the marker in 4 built files, runtime `-t 33153`: 2 red (both LITs), the control green. Restore leg: lint rebuilt, `--absent` found the marker in 0 of 20 built files, tree clean, 3/3 green. ## Acceptance notes - **Exposure measured:** `git grep` of `objectExtensions` / `defineObjectExtension` over `examples/`, `packages/` (non-test) and HotCRM `origin/main`: two entries, neither adds a `formula` field. - **A field an extension redeclares under a name the target already serves** is served as the written definition. In the build the object walk judges a re-declared declared field under its name, at the object, so the extension walk leaves the authored target's declared names out rather than naming one twice. At the door, whose one pass skips the object walk and whose target is served before the write (other packages' published extension fields included), no name is left out, so both a package re-declaring a field of an object it owns and an entry re-adding a name a sibling package's extension serves are refused at the entry (review round 1, finding 1; `protocol-extension-redeclared-owner-field.ts` does not judge an extension of an object its own package owns, so nothing else refused that shape). - **A field two packages add at the same priority**, in `os build` on a declared target, is left out of the served body (`objectsWithoutTiedFields`) and so out of the cycle pass, as objectstack-ai#33398 leaves its hops unjudged: which definition is served is registration order. On an undeclared target the build takes the later entry's definition of a shared name and judges it. - **The door's reading of a shared name** (review round 2): the door snapshot carries a sibling package's published extension field as a plain field with no priority, and folds the written entry over it, so the door judges the written entry's own definition of every name it adds. On a tie, or where a sibling outranks the written entry, the door can refuse a cycle the build lets through. Ruled text plus a pin, no code change here; follow-up objectstack-ai#33494 makes the door read the build's winner. The semantic entry, the changeset's Unchanged list, the call-site comment and the docs sentence state both readings. - **Not changed, by the order's fence:** the gate-setup region of `validate-expressions.ts` (objectstack-ai#33246's), `authoring-rules.ts` and the door roster pins (the rule already runs on the door). ## Verification Head `bfa139ba` (base `fc283d6d`; review round 1 adds `88b22a14` and `7c2eeb88` over `67ff848e`, round 2 adds `bfa139ba`). `origin/main` has moved to `811b976a`; `git diff --stat fc283d6 811b976` over every file this PR touches is empty, so no merge was needed. objectstack-ai#33246 (PR objectstack-ai#33434) had not merged. <details><summary>Package tests</summary> - `@objectstack/lint`: 210/210 files, 8982/8982 tests; `pnpm --filter @objectstack/lint typecheck` (tsc + test typecheck) exit 0. - `@objectstack/runtime` `src/domains/meta-object-extension-item.test.ts`: 46/46; `pnpm --filter @objectstack/runtime typecheck` exit 0. - `@objectstack/spec` `src/migrations`: 5 files, 198/198. </details> <details><summary>Gates (dispatch-gates --commands, 109 lines)</summary> The derivation at `bfa139ba` is 109 lines, the same list as at `67ff848e` and `7c2eeb88`. Every line ran after a whole-repo `pnpm build` of `bfa139ba`, its exit code captured before any pipe, and all 109 exited 0. `dispatch-gates --ran`: `109 derived, 109 run, 0 NOT-MEASURED`. The record is `pm-orders/spec/33153-gates-ran-r2.txt` in the project share (earlier rounds: `33153-gates-ran.txt`, `33153-gates-ran-r1.txt`). </details> Dogfood (`Clause-②:` carries the `(narrowing)` arm and the title `!`): full battery, the CI command (`pnpm --filter @objectstack/dogfood test` under the verify lock), no shard, on head `bfa139ba` after a whole-repo build. Result: `VERDICT command-exit 0`, Test Files 465 passed and 3 skipped (468), Tests 3932 passed and 42 skipped (3974), no failures (the same counts as on `67ff848e` and `7c2eeb88`). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5mAXtyZgMs9QwfQzXE)_ <!-- signed: domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…s the written entry among other packages' extensions by priority, as os build does (objectstack-ai#33702) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X5DTB6H6vWGj3p1JFrKB58W)_ Fixes objectstack-ai#33494 Clause-②: no (narrowing) — at the runtime `object_extension` publish door (Studio, `PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors) the expression rule now reads each field of the target as `os build` serves it when another package's published extension adds the same field. One shape it accepted is now refused (shape 3: a higher-priority package's formula for a field the written entry also adds closes a cycle through another field of the entry), and two it refused now publish (shape 1, a tie at the priority that decides the field; shape 2, the written entry outranked there). `os build`, `os validate` and `os lint` are unchanged. The new gate input (`storedObjectExtensions` on `runRuntimeAuthoringRules` and `evaluateRuntimeAuthoringGate`, the `StoredObjectExtension` type from `@objectstack/lint/runtime`) is optional and additive. Measured first-party exposure: no two first-party packages extend the same object (`examples/app-showcase` one entry on `showcase_account`; `packages/plugins/plugin-auth` one on `sys_sso_provider`; HotCRM `origin/main` 2492ac6 one module, o2c, extending `crm_contract` and `crm_account`), so no first-party write changes verdict. Metadata-protocol: narrowed Skills-docs: none owed — this PR edits `content/docs/deployment/validating-metadata.mdx` (the object extension paragraph states the door's fold); the skills teach `defineObjectExtension({ extend, fields, priority })` and formula fields and say nothing of how the door read a field two packages add. ## 维护者速读 - **改了什么**:运行时 `object_extension` 发布口在判断扩展字段(如公式循环)时,现在把其他软件包已发布的同目标扩展连同其优先级一起折叠,用的是 `os build` 的同一个折叠函数,所以发布口看到的字段定义与 build 一致:同优先级冲突的字段两边都不判,被更高优先级覆盖的字段按覆盖者的定义判。 - **为什么改**:此前发布口拿到的目标对象里,其他包加的字段是没有优先级的普通字段,写入条目总是盖在上面。结果有两种情况发布口拒绝而 build 放行(同优先级、被更高优先级覆盖),一种情况发布口放行而 build 拒绝(更高优先级的兄弟公式经由本条目的另一个字段构成循环)。 - **风险与回滚**:发布口一处收窄、两处放宽,build 不变。需要两个软件包扩展同一对象的同名字段并带公式循环才会触发;第一方实测没有两个包扩展同一对象。新输入是可选的,宿主不提供时行为与之前相同。回滚即 revert。 - **先看**:`packages/lint/src/validate-expressions.ts`(扩展遍历:stored 条目只折叠不判定、回填跳过 stored 名称)、`packages/lint/src/object-graph.ts`(`objectExtensionsByTarget` / `objectsAsServed` 的 `stored` 参数)、`packages/metadata-protocol/src/protocol-authoring-gate.ts`(`otherPackagesExtensionsOf`)。 - **两分钟验证**:`pnpm --filter @objectstack/lint exec vitest run src/runtime-gate.object-formula-cycle.test.ts`,预期 20 条全过,其中 `objectstack-ai#33494` 一组 5 条:同优先级与被覆盖两种情形发布口与 build 都放行,更高优先级兄弟公式构成的循环在发布口按本条目的字段拒绝。 - **需要你做的**:无,席位落地。 ## What changes **`packages/lint/src/object-graph.ts`.** `objectExtensionsByTarget(stack, stored = [])` and `objectsAsServed(stack, stored = [])` take an optional list of `StoredObjectExtension` (an extension the host's registry already holds for another package: `extend`, `priority`, `fields`, `packageId`). Each is collected by the fold's own `collect`, one carrier per entry below 0 (registered before the stack's own entries), marked `stored: true` on its `VisibleObjectExtension`. They sort and fold exactly as any entry: ascending priority, a later writer replacing the whole field, a name whose deciding writers share a priority put in `tied`. The build never passes the list, so every build verdict is what it was. **`packages/lint/src/validate-expressions.ts`.** `StackExpressionOptions.storedObjectExtensions`, read on an `object_extension` write only (`storedExtensions`). It reaches the top-of-pass fold (`objectsAsServed(stack, storedExtensions)`, so the field, type and nullable indexes see the build's winner and leave a tie out) and the extension walk (`objectExtensionsByTarget(stack, storedExtensions)`). In the walk a stored entry is folded in and never judged or located; the fill-back from `base` (the target as served before the write, which carries the stored entries' fields as plain fields) skips the names they add, so a tied name is not served again as one sibling's definition. The call-site comment is rewritten to this reading. Neither edit touches the gate-setup region PR objectstack-ai#33434 edits (its hunks at ~:2374-2380 and after ~:2396; this PR changes the one fold call between them, as the seat's surface amendment allows). **`packages/lint/src/formula-cycle-issues.ts`.** `extensionFormulaLoci` reads `stored`: a stored entry locates nothing, and a name it adds later in fold order than the written entry removes the written entry's locus (the sibling's definition is the one served). So a cycle a higher sibling closes through another field of the written entry is named on that field alone, and the sibling's member is never charged to the write. **`packages/lint/src/runtime-gate.ts`, `authoring-rules.ts`, `runtime.ts`.** `runRuntimeAuthoringRules({ storedObjectExtensions })` (optional) hands the list to `AuthoringRuleContext.storedObjectExtensions` on an `object_extension` write only, the same value in every pass; the expression rule passes it to `runStackExpressionPasses`. `@objectstack/lint/runtime` exports the `StoredObjectExtension` type. **`packages/metadata-protocol/src/protocol-authoring-gate.ts`, `runtime-authoring-gate.ts`.** New `otherPackagesExtensionsOf(registry, target, writtenPackage)`: each `extend` contributor of the target (`getObjectContributors`) of a package other than the written one, with its priority and fields, in the registry's order; a disabled package's left out (`isPackageDisabled`, as every served fold withholds it); `[]` for a registry that cannot answer. `judgeRuntimeAuthoringRules` states it on an `object_extension` write (the target and package `objectExtensionWriteFold` already names) and `evaluateRuntimeAuthoringGate` passes it through (optional `storedObjectExtensions`). No `packages/spec` schema moves: the registry already held each sibling's package and priority. **`packages/spec/src/migrations/entries/semantic/18.object-extension-formula-cycle-refused.ts`** (PR objectstack-ai#33442's entry, not yet released): `reason` and `acceptanceCriteria` now state the door's fold, "at the priority that decides it" in place of "at the same priority", and the tie exception for both the build and the door on a declared object. **`content/docs/deployment/validating-metadata.mdx`**: the object extension paragraph's last sentence states the door's fold and "at the priority that decides it". **`.changeset/33494-extension-door-priority-fold.md`**: `@objectstack/lint`, `@objectstack/metadata-protocol` and `@objectstack/spec` minor, both declaration lines, the `Skills-docs:` line, a BREAKING banner (Before / Now / Unchanged / Fix) and `adr-0087: not-required (already-registered object-extension-formula-cycle-refused)` (this PR updates that unreleased entry rather than registering a new one). Its **Now** paragraph corrects, by quotation, the pending `.changeset/33153-extension-formula-cycle.md` Now clause and Unchanged sentence the carry note 6886038545 names, and "at the same priority" there. That changeset is not edited (it is another PR's). ## Why Card objectstack-ai#33494 (from PR objectstack-ai#33442's contract review, record 6885259034 finding 1 and its observation): the door's snapshot (objectstack-ai#33072) carried every other package's extension field on the target as a plain field with no priority, so the gate folded the written entry over all of them. `os build` folds every package's entry by priority and serves the winner. The door refused a tie and an outranked entry the build accepts, and accepted a higher sibling's cycle through another field of the entry that the build refuses. ## Tests 1. **`packages/lint/src/runtime-gate.object-formula-cycle.test.ts`**: the objectstack-ai#33153 pin "the door judges the written entry's own definition whatever a sibling's priority" is replaced by a `objectstack-ai#33494` describe (5 cases) at the real gate (`runRuntimeAuthoringRules`, `type: 'object_extension'`, with `storedObjectExtensions`) and the build (`runAuthoringRules('build', …)` over both packages): - ⭐ shapes 1 and 2: a tie (200/200) and an outranked entry (sibling 300, written 200), the written `s__c` reading itself: no cycle finding at the door, none in the build. - ⭐ LIT shape 3: the sibling (300) serves `s__c = record.a__c + 1`, the written entry (200) adds `s__c` (number) and `a__c = record.s__c * 2`: refused at the door on `a__c` only, in the engine's sentence (`formulaCycleMessage('a__c', ['a__c', 's__c'])`); the build names the sibling's `s__c` at the sibling's entry and `a__c` at the written entry. - the entry that outranks the sibling (300 over 200) is still refused at the door at the entry, and by the build at the same entry. - a tied name the sibling stored as a self-reading formula is not served back from the target and not charged to the write (door and build both clean). - a host that states no extensions leaves the door as it was (the written entry folded over the served target). 2. **`packages/runtime/src/domains/meta-object-extension-item.test.ts`**, new describe `[objectstack-ai#33494]` (4 cases) through the real `saveMetaItem` + `publishMetaItem`, with a third package registered as an extender of the account (`registerObjectExtension`, priority 200 or 300): ⭐ the tie and the outranked self-reading formula publish (the row goes active), as `os build` accepts each; ⭐ shape 3 gets 422 `INVALID_METADATA` with `expression-invalid` at `object 'crm_account' · objectExtensions[0] · field 'a__c' expression` and the row stays a draft; CONTROL: an entry outranking the sibling with a self-reading formula is still refused. 3. **`packages/metadata-protocol/src/protocol-authoring-gate.extension-write-fold.test.ts`**, new describe `[objectstack-ai#33494]` (2 cases): `otherPackagesExtensionsOf` lists every other package's `extend` contributor in the registry's order with its priority and fields, leaving out the owner, the written package and a disabled package; a registry with no contributors member, or one that throws, states none. 4. **Meta-tests** (`validate-expressions.test.ts`, `validate-security-posture.test.ts`, objectstack-ai#5017 receiver scans): `storedNames` (a Set of names) and `stored` (the fold's list parameter) tabled as plumbing receivers, each with its reason. **Red at base:** the head's lint test file over the base lint sources (`git restore --source=41b64bb0` of the six lint source files): 2 of 20 red, the shapes 1/2 case and the shape 3 LIT; restored with `git checkout HEAD --`, `git diff HEAD` empty. **Ablations** (one-shot through `node scripts/ablation-replace.mjs` on committed head `e681d49f`; each restore verdict "blob == HEAD and `git diff HEAD` is empty"; lint tests read `src/`): - A1, the fill-back skip (`&& !storedNames.has(n)` dropped): 1 of 20 red, the tied-name case. - A2, stored entries locating (`if (entry.stored) loci.delete(name)` made unreachable behind a `globalThis` marker): 1 of 20 red, the shape 3 LIT (the sibling's `s__c` charged to the write). A first attempt was a no-op (its replacement kept the anchor text; the tool refused and restored), so it was rerun with the marker. - A3, the top fold without the stored list (`objectsAsServed(stack)`): 2 of 20 red, shapes 1/2 and shape 3. - R1, the host carry, for the runtime pins that read metadata-protocol through `dist/`: the registry handed as `globalThis.__ablationR1` (undefined) in `judgeRuntimeAuthoringRules`, `pnpm --filter @objectstack/metadata-protocol run build`, `ablation-dist-preflight` found the marker in `dist/`, runtime `-t 33494`: 3 red (both publish LITs and the shape 3 LIT), the CONTROL green. Restore leg: rebuilt, `--absent` found no marker, 4/4 green. (A first R1 attempt was also a no-op for the same reason and is not counted.) ## Acceptance notes - **Where the snapshot is built** (measured): `packages/metadata-protocol/src/protocol-authoring-gate.ts` (`judgeRuntimeAuthoringRules`), not `packages/runtime/src/domains/`; the seat amended the claim's surface (6888588670). - **No second fold.** The door's fold is `objectsAsServed` / `objectExtensionsByTarget` with the host's entries added to their input; the tie set and the ordering are the build's. - **A tied name the target's owner also declares**: in the build the tied name is filled back from the authored object (the object walk's); at the door the target's base layer is not carried (only the served target), so the walk leaves every name a stored entry adds to the fold, and such a name is absent there. It needs an owner field re-declared by two packages at the priority that decides it, plus a formula cycle through it; the verdict charged to the write can only differ by a member under that name. Noted, not filed. - **A disabled package's extension** is left out (`isPackageDisabled`), as the served fold leaves it out; an enable door's `asEnabled` reading is not this write's. - **The legacy `NS__NAME` filing** (`extensionTargetKey`, objectstack-ai#28858) is not mirrored: the host reads the contributors under the target the body names, as the gate folds it. - **Other as-served checks on this door** read the same fold now (the field-formula and validation-rule passes' field, type and nullable indexes), so a type or null-guard verdict on a field another package outranks is the build's too. - **Not changed, by the order's fence:** `packages/spec` schemas; the door roster and its pins; PR objectstack-ai#33434's hunks. ## Verification Head `763105ec`: the fix `e681d49f`, the meta-test tabling `78ad84f3`, the ADR-0087 marker `dd37779e`, and a merge of `origin/main` `e9884e19` (base `41b64bb0`). PR objectstack-ai#33434 landed before the merge; it merged clean, and both its stamped-column index and this PR's `objectsAsServed(stack, storedExtensions)` are on the merged line. <details><summary>Package tests</summary> Run on head `763105ec` (the merge of `origin/main` `e9884e19`, which brought PR objectstack-ai#33434) after a whole-repo `pnpm -r run build` (`VERDICT command-exit 0`): - `@objectstack/lint` `pnpm test`: 210/210 files, 8998/8998 tests; `pnpm --filter @objectstack/lint typecheck` (tsc + test typecheck) exit 0. - `@objectstack/metadata-protocol` `pnpm test`: 340 files passed and 9 skipped, 22883 tests passed and 43 skipped; `typecheck` exit 0. - `@objectstack/runtime` `src/domains/meta-object-extension-item.test.ts`: 50/50; `pnpm --filter @objectstack/runtime typecheck` exit 0. - `@objectstack/spec` `src/migrations`: 198/198 (round 0, on `e681d49f`; the entry's text has not moved since). </details> <details><summary>Gates (dispatch-gates --commands)</summary> The derivation at `763105ec` is 114 lines. Every line ran after the whole-repo build of `763105ec`, its exit code captured before any pipe, and all 114 exited 0. `dispatch-gates --ran`: `114 derived, 114 run, 0 NOT-MEASURED, 0 UNRUN`. The record is `pm-orders/spec/33494-gates-ran.txt` in the project share. Round 0 (head `78ad84f3`, before the merge): the same 114 lines, 112 exit 0 and 2 red, each fixed and rerun green: `check-adr-0087-registration` (the changeset said `registered` for an entry that already existed; now `not-required (already-registered …)`, commit `dd37779e`) and `check-plugin-teardown-shape --self-test` exit 3 (the shallow clone lacked the pinned fixture commit; `git fetch --depth=1 origin 621a487…`). Record: `pm-orders/spec/33494-gates-ran-r0.txt`. </details> Dogfood (`Clause-②:` carries the `(narrowing)` arm and the title `!`): full battery, the CI command (`pnpm --filter @objectstack/dogfood test` under the verify lock), no shard, on head `763105ec` after a whole-repo build. Result: `VERDICT command-exit 0`, Test Files 467 passed and 3 skipped (470), Tests 3958 passed and 42 skipped (4000), no failures. (Round 0 on `dd37779e`, before the merge: 467/3 files, 3953 passed and 42 skipped, no failures.) ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pZiFTTaXqbY34YRcV)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
…injected column a stored row can hold null in, as the publish gate does (objectstack-ai#34129) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9TDTX7iNkw3ugZTbLqZFUtx)_ Fixes objectstack-ai#33435 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: none — no skill under `skills/**` teaches a condition over an injected column or the null guard on one; `content/docs/automation/flows.mdx` and `content/docs/automation/hooks.mdx` gain the rule in this change. > **BREAKING** for a stack whose record-triggered flow condition or hook `condition` orders or does arithmetic on an injected system column the object does not declare (`owner_id`, `created_by`, `updated_by`, `owning_business_unit_id`, `queue`, `organization_id`; `created_at` / `updated_at` at a `beforeInsert` hook) with no `!= null` guard: `os build` now refuses it, as the runtime publish gate already did. ADR-0087: `registered flow-hook-condition-injected-column-null-guard-at-build`. ## 维护者速读 - 改了什么:`os build` 在 flow 条件和 hook 条件里,对平台注入列(负责人、创建人、修改人、业务单元、队列、组织)做大小比较或算术而没先判空时,现在会报错,和发布时的服务端检查给出同一条结论;`beforeInsert` 钩子里的创建/修改时间也一样。 - 为什么改:实测这些列在系统写入、种子数据、访客写入的行上是空的,条件一碰就出错:flow 跑失败(触发它的写入照样落库),hook 条件直接让写入失败。以前本地构建放行、发布才拒,作者在发布时才第一次看到错误。 - 风险与回滚:只收紧构建期检查,运行时与发布检查不变;四个示例应用和平台对象零命中。回滚即还原 `validate-expressions.ts` 的这次改动。 - 先看:`packages/lint/src/validate-expressions.ts`(`buildInjectedNullableIndex` / `buildPreStampIndex` 和 `checkNullGuards` 的 `nullable` 选项),`packages/lint/src/validate-expressions.flow-null-guards.test.ts` 新增的对齐用例。 - 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-expressions.flow-null-guards.test.ts`,应见 29 passed,其中 objectstack-ai#33435 的用例逐列断言构建与发布检查结论相同。 - 需要你做的:无,席位落地。 ## What changes - `packages/lint/src/validate-expressions.ts`: the flow condition sites (start, edge, `decision` branch; `record.` and bare spellings) and the hook condition site now judge the null guard over the declared fields **plus** the injected system columns the object as read does not carry (`buildInjectedNullableIndex`). At `os build` that is every injected column the author did not declare; at a single-item runtime door the objects are served with those columns declared, so the index adds nothing there and its verdicts do not move. Two runtime readers hand the walk authored objects and so narrow with the build, inside the declared narrowing: the MCP `validate_expression` tool at site `flow_condition` (`judgeAuthoredSiteExpression` strips the injected columns and runs the walk as a flow write) now returns the null-guard finding for the six columns, and a `publish-drafts` batch that carries a draft of the flow's or hook's own object (`mergePendingDeclarations` replaces the served object with the draft body, which holds no injected column) now refuses what it published before, as the single-item publish already refused it. A hook whose `events` include `beforeInsert` also judges `created_at` / `updated_at` (`buildPreStampIndex`), the card's S1 case. Validation rules and `requiredWhen` keep the declared-field index: both doors judge those over the authored object (measured below), so they already agree. - The `PLATFORM_STAMPED_COLUMNS` docblock records the per-column measurement; the orphaned `buildNullableFieldIndex` docblock (it said leaving the injected columns out "costs coverage, never a false error") moves above its function and says what the index is now. - `packages/spec/src/migrations/entries/semantic/18.…` `reason`: a `beforeInsert` hook reads `created_at` / `updated_at` as null only when it runs before the stamp (priority below 10); the rule stays the door's (objectstack-ai#33434), a priority-aware rule at both doors is the seat's follow-up. - `content/docs/automation/flows.mdx` (rule 5) and `content/docs/automation/hooks.mdx` (the `condition` gate) state that the injected columns need the guard and the two timestamps do not, except at `beforeInsert`. - ADR-0087 semantic entry `flow-hook-condition-injected-column-null-guard-at-build`; root changeset `33435-injected-column-null-guard-at-build.md` (`@objectstack/lint` and `@objectstack/spec` minor). ## Measurement (card step 1) <details><summary>Per column, per ownership tier, per writer (showcase, real REST door + engine, driver-sqlite-wasm, single posture)</summary> Throwaway probe (deleted): the showcase stack plus three objects, one per ownership tier (default/user, `business_unit`, `org`), a REST `POST /data/OBJECT` as the platform admin and as a signed-up member, then `ql.insert` under `{ isSystem: true }` with and without `tenantId`, a system update and an admin REST update of each system row; hooks registered at priority 1 recorded what each event saw; three record-after-create flows on the user-tier object. | column | REST create (admin, member) | system insert | after a user REST update of a system row | seeded `showcase_task` | |---|---|---|---|---| | `organization_id` | set | set (Default Organization) | set | set | | `owner_id` (user tier) | stamped to the caller | NULL | NULL | claimed by the admin | | `queue` (user tier) | NULL | NULL | NULL | NULL | | `owning_business_unit_id` (user, business_unit tiers) | NULL | NULL | NULL | NULL | | `created_by` | stamped | NULL | NULL | NULL | | `updated_by` | stamped | NULL (a system update leaves it NULL) | stamped | NULL | | `created_at`, `updated_at` | set | set | set | set | - A `beforeInsert` hook at priority 1 saw a payload with no `organization_id`, `created_at`, `updated_at`, `created_by` for every writer (REST and system); `afterInsert` saw them stamped. `organization_id` is filled by the driver after the hook chain. - Reach: system inserts fire record-triggered flows and every hook. `record.owner_id > 'a'` and `record.created_by > 'a'` start conditions: each system insert's run `failed` with `condition failed to evaluate as CEL: no such overload: dyn<null> > string`; the REST create's run `completed`; the guarded `record.owner_id != null && record.owner_id > 'a'` flow never failed. - `posture-only` (isolated) boot: a system-context insert with no organization is refused (`SystemWriteOrganizationRequiredError`, ADR-0131 D9), so no NULL row there. - By design, not re-measured: a guest/public-form write leaves `owner_id` unset (ADR-0138 D1 item 5), a queue park or release writes `owner_id: null` (ADR-0142 D3, `content/docs/automation/queues-and-assignment-rules.mdx`), and driver-memory never stamps a tenant column (`packages/drivers/driver-memory/src/memory-tenancy-guard.ts` header). Decision (card step 2): no column is stamped for some ownership tiers only, so no STOP. `owner_id`, `created_by`, `updated_by`, `owning_business_unit_id`, `queue` hold NULL on reachable stored rows ⇒ nullable at both. `organization_id` is set on every stored row on the SQL family but read NULL at `beforeInsert` and never stamped by driver-memory ⇒ not every reachable row, so it stays nullable at the door and is now nullable at the build (the door already judged it so). `created_at` / `updated_at` stay never-null except at a `beforeInsert` hook (S1). Gate-level reading before/after (lint functions, same object, every tier): base `f81e4b6c` — flow/hook sites door=1 build=0 for each of the six columns, `beforeInsert` hook on `created_at`/`updated_at` door=1 build=0, validation rule door=0 build=0; head — build equals door in every cell. </details> ## First-party exposure (card step 3) `objectstack build` at head in `examples/app-todo`, `app-crm`, `app-multi-package`, `app-showcase`: exit 0 each, zero null-guard findings. Positive control: `examples/app-todo`'s `todo_task_completion` start condition with `&& record.created_by > "a"` appended (via `scripts/ablation-replace.mjs`, restored, `git diff HEAD` empty) ⇒ exit 1 with `applies \`>\` to \`record.created_by\``. Platform packages: `git grep` finds no flow or hook condition ordering an injected column (`examples/app-showcase/src/ui/actions/predicate-matrix.action.ts` uses `owner_id ==` in an action `visible`, not a judged site). No hit to guard. ## Tests - `packages/lint/src/validate-expressions.flow-null-guards.test.ts`: the objectstack-ai#33246 describe is renamed to cover both cards and gains seven cases: os build refuses each of the six columns at every flow slot and at a hook with the door's exact finding; a flow's bare spelling (judged as a declared nullable field's, the door judges no bare name of either kind); per ownership tier the build judges exactly the columns the tier carries; the S1 `beforeInsert` case and its afterInsert/flow controls; the guarded spelling; an author-declared `owner_id` keeps its own verdict; a validation rule keeps its verdict at both. - `packages/lint/src/authored-site-expression.test.ts`: the MCP `flow_condition` entry over a served object returns the gate's null-guard finding for `record.owner_id > 'a'`, and nothing for the guarded spelling. - `packages/metadata-protocol/src/runtime-authoring-gate.injected-column-null-guard.test.ts` (new): `evaluateRuntimeAuthoringGate` with the object's draft in `pending.objects` refuses a flow over `owner_id` and a `beforeInsert` hook over `created_at` exactly as the single-item publish does; the guarded spelling publishes. Ablation: with base `validate-expressions.ts` (lint rebuilt) both batch cases and the MCP case fail; restored, they pass. - Forced test edit: `packages/lint/src/validate-expressions.test.ts` — the objectstack-ai#5017 declared-keys meta-test's `PLUMBING` table gains the five new non-metadata receivers (`flowHookNullableIndex`, `preStampIndex`, `carriedFieldNames`, `joinedNullable`, `joinedFields`). ## Acceptance notes - Out of scope, named for the seat: a hop leaf through an injected lookup (`record.owner_id.nmae != null`) is judged at neither the build nor the door. - Residual build/door difference left on purpose (the order scoped `created_at` / `updated_at` to the S1 case): the door also refuses, and the build accepts, arithmetic on `record.created_at` in a flow, a `previous.created_at` read, a read-event hook (`beforeFind` / `afterFind`) on the two timestamps, and every timestamp read on an `external` object. - Validation rules and `requiredWhen` over an injected column are judged at neither door (the object door judges the authored object); a stored row with NULL there faults the rule. Same class, not this card's sites. - The null-guard message names the object as declaring the column nullable ("'todo_task' declares as nullable (no `required: true`, no `defaultValue`)") for an injected column the author never declared; it is the door's existing wording, kept identical for parity. ## Verification All readings at head `f1e07bac` (the final commit), worktree on `origin/main` `f81e4b6c`. <details><summary>Tests, consumers, dogfood, gates</summary> - `pnpm --filter @objectstack/lint test`: Test Files 212 passed (212), Tests 9033 passed (9033); `pnpm --filter @objectstack/lint typecheck`: exit 0 (lock VERDICT command-exit 0). - Consumers of the build verdict (the contract face is `os build` / `os validate`; the single-item door's verdicts do not move; the MCP `flow_condition` entry and `publish-drafts` batches move as "What changes" says): `pnpm --filter @objectstack/cli exec vitest run --project unit` 423/423 files, 6010/6010 tests; `@objectstack/metadata-protocol` 342 passed, 9 skipped files, 22926 passed, 45 skipped tests; `@objectstack/mcp` 65/65 files, 1185/1185; `@objectstack/platform-objects` 122/122 files, 2007/2007. All exit 0. - Full dogfood battery (`(narrowing)` arm), `pnpm --filter @objectstack/dogfood test` under the verify lock: VERDICT command-exit 0, Test Files 467 passed, 3 skipped (470), Tests 3962 passed, 42 skipped (4004). - `objectstack build` in the four examples: exit 0 each; positive control exit 1 (see First-party exposure). - `node scripts/pm/dispatch-gates.mjs --commands` (no paths): 109 commands, each run with stdin closed and the exit captured before any pipe; `--ran`: 109 derived, 108 run, 1 NOT-MEASURED, 0 UNRUN. NOT MEASURED: `pnpm check:dual-build-cjs-loads`, reason: exit 3 PREREQUISITE NOT MET (not every package has a `dist/`), CI runs it. Three first-pass exit 3 refusals re-run green after their prerequisite: `check-plugin-teardown-shape.mjs --self-test` (shallow clone; `git fetch --depth=1 origin 621a487`, 48 cases), `check:skill-examples` (built `@objectstack/client-react...`; 346 prose examples), `check:type-check-debt` (lock wait behind the dogfood run; re-run with a slot, OK). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmS2qjQvEgMBSBQpeea)_ <!-- signed: domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Leehom · project thread
Fixes #33246
Clause-②: yes (widening) — the flow and hook publish doors (Studio,
/api/v1/meta, the MCP and AI authoring doors) now accept a condition they refused andos buildaccepted:created_atorupdated_at(as the registry injects them, on an object whose storage the platform provisions) read off the current row (bare in a flow, orrecord.) as an operand of<,<=,>or>=with no!= nullguard, in a record-triggered flow or in a hook whose every event isafterInsert,beforeUpdate,afterUpdate,beforeDeleteorafterDelete. Nothing that published before is refused, and no other verdict moves: arithmetic over either column, aprevious.read, abeforeInsertor read-event hook, and the other six injected columns keep their verdicts (measured below).os build,os validate,os lintand MCPvalidate_expressionare unchanged. No exported type or signature changes.Metadata-protocol: added
Skills-docs: none owed — no skill teaches that
created_atorupdated_atneeds a null guard in a flow or hook condition, or that the door refuses one; the door now gives the verdictos buildalready gives on those two columns under an ordering comparison.Precedent followed: #33154 (PR #33205) for the door-versus-build reading. Round 2 answered contract review 6884221427 under seat rulings 6884227999 (F1, F2, F3, N2; N1 declarations kept). Round 3 answered delta review 6884875891 under seat rulings 6884884180 (M1, S1, N3, N4, N5). Round 4 answers review 6885550922 under seat rulings 6885555312 (M2, S2, N6).
维护者速读
created_at、updated_at作为比较运算(<<=>>=)的操作数不再报可空;仅限当前记录的这两列(流里的裸名或record.,不含previous.)、平台自己注入的定义、对象的存储由平台建表(外部对象不算),且钩子的每个事件都在afterInsert、beforeUpdate、afterUpdate、beforeDelete、afterDelete之内。算术运算(+ - * / %)、previous.读取照旧判定;其它六个注入列(owner_id、created_by、updated_by、owning_business_unit_id、queue、organization_id)照旧按可空判定;所有注入列的类型判定照旧。record.created_at > timestamp(...)没加空值守卫会被发布口拒绝(422),而os build通过、MCPvalidate_expression也说没问题。平台在beforeInsert(sys_stamp_audit_insert,优先级 10)里给每条记录写这两列,之后读到的都有值,拒绝是误报。record.created_at + 1 > 0与record.updated_at - record.created_at > duration('1h')照旧拒绝;beforeInsert钩子照旧拒绝(可能先于平台写入运行);读事件(beforeFind、afterFind)钩子照旧拒绝(没有记录);afterInsert钩子或新建流里的record.updated_at > previous.updated_at照旧拒绝(新建时previous为空);其它六个注入列、作者自己声明的created_at、外部对象照旧。发布口与 build 在六列及beforeInsert、读事件钩子上的差异留给 lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435。回滚即 revert。packages/lint/src/validate-expressions.ts(PLATFORM_STAMPED_COLUMNS、isPlatformStampedColumn、buildPlatformStampedIndex、isStampedComparisonFinding、hookReadsStampedRow)、packages/runtime/src/domains/meta-flow-hook-injected-column-null-guard.test.ts(真实发布口)、packages/lint/src/validate-expressions.flow-null-guards.test.ts(A flow or hook condition ordering record.created_at with no guard is refused at the publish door while os build accepts it #33246 一节)。pnpm --filter @objectstack/lint exec vitest run src/validate-expressions.flow-null-guards.test.ts -t 33246,预期 10 条全过:两列无守卫比较在流三处与钩子都通过;五个可空注入列照旧拒绝;日期运算照旧拒绝(钩子、流裸写、动作);流里record.写法的算术照旧拒绝;beforeInsert钩子照旧拒绝;previous.读取照旧拒绝;读事件钩子照旧拒绝;作者声明与外部对象的created_at照旧判定;声明的可空字段照旧拒绝。What changes
packages/lint/src/validate-expressions.ts.PLATFORM_STAMPED_COLUMNS(created_at,updated_at) andisPlatformStampedColumn(obj, field, def): true only when the field is one of the two, its definition is the platform's own (isInjectedColumnDefinitionagainstinjectedSystemColumnDefs(obj)), and the platform provisions the object's storage (platformProvisionsStorage, so not an ADR-0015externalobject). The two names are the ones@objectstack/objectqlstamps on every row (sys_stamp_audit_insert, abeforeInserthook at priority 10, writes both unconditionally). This package may not import a runtime, so they are spelled here, with that reference in the docblock.buildPlatformStampedIndex(objects)(object → its stamped columns) is built on every runtime write (options.runtimeWriteType !== undefined); the build gets an empty index.buildNullableFieldIndexis back tomain's signature and body: the nullable index still holds both columns.checkNullGuardstakes{ stampedComparisons }(defaulttrue) and drops a finding only whenisStampedComparisonFindingholds: the operand is a stamped column of that object read off the current row (bare, as a record-triggered flow flattens its trigger record, orrecord.<column>), and the operator is<,<=,>or>=. Aprevious.<column>operand keeps its finding andPREVIOUS_GUARD_CLAUSE(M2): an insert bindspreviousitself tonull. An arithmetic operand (+ - * / %) keeps its finding (M1): at a record-triggered flow'srecord.read the null guard is the door's only refusal of date arithmetic, because the flattened site type-checks only the bare spelling.stampedComparisons: hookReadsStampedRow(hook.events): true only wheneventsis a non-empty list and every event isafterInsert,beforeUpdate,afterUpdate,beforeDeleteorafterDelete. AbeforeInserthook (S1) can run before the stamp, at anypriority, and read either column asnull; abeforeFind/afterFindhook (S2) carries no record.object_extensionstrip ismain's (only that write reads the objects stripped). Every other door keeps the served objects, sofieldTypeIndexand every other reader still see the injected columns' types.created_at/updated_atat the three record-triggered flow sites and in a hook condition whose every event reads a stamped stored row publishes, when the read is the current row's. Everything else is judged as onmain.packages/lint/src/validate-expressions.test.ts: the validate-expressions / validate-security-posture 也有同形的 spec 不声明键的??别名读法(#5009 建议 3 的核对结果) #5017 declared-key meta-test'shookrow now listsevents(a declaredObjectStackSchema.hooks[]key), and its plumbing set namesplatformStampedIndex/stamped/hookEvents(Map / Set / Array locals). The meta-test forces that visit for any new read..changeset/33246-door-skips-stamped-timestamps-in-comparisons.md(renamed from round 1's33246-door-reads-objects-as-authored.md):@objectstack/lintminor, both declaration lines, Before / Now / Unchanged. Unchanged names arithmetic at every door (the flowrecord.spelling included), the author-declared andexternalcreated_at, aprevious.read, abeforeInsertor read-event hook, the six injected columns still judged nullable (organization_idincluded), and the door/build difference on those six and on abeforeInsertor read-event hook until lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435. Its Now paragraph gives the stamp as the warrant (N6).content/docs/deployment/validating-metadata.mdxdoes not describe the door's null-guard reading, so it is not edited.Tests
packages/lint/src/validate-expressions.flow-null-guards.test.ts, top-level describe#33246(10 cases), at the gate (runRuntimeAuthoringRules, the account as the registry serves it viaapplyInjectedSystemColumns) and at the build (runAuthoringRules('build', …)). Five writes per condition: a flow with it at the start node, an edge and adecisionbranch; a hook on'crm_account'and on['crm_account'].record.created_at > timestamp('2025-01-01T00:00:00Z')andrecord.updated_at > record.created_at: no expression finding at the door or the build.record.COLUMN > 'a'for each ofowner_id,created_by,updated_by,owning_business_unit_id,queue: one null-guard finding naming the column at the door.record.created_at + 1 > 0andrecord.updated_at - record.created_at > duration('1h')at a hook, barecreated_at + 1 > 0at a flow start and edge, andrecord.created_at + 1 > 0as an actionvisible: each refused withdate arithmetic.record.created_at + 1 > 0andrecord.updated_at - record.created_at > duration('1h')at a flow start condition: each refused with a null-guard finding on the column.record.created_at > timestamp(…)on a hook withevents: ['beforeInsert']and['beforeInsert', 'beforeUpdate'], on a string and a listobject: refused with a null-guard finding; the same condition on anafterInserthook: no finding.record.updated_at > previous.updated_atin anafterInserthook and at arecord-after-createflow start: one finding each, onprevious.updated_at, whose message namesprevious != null && previous.updated_at != null.record.created_at > timestamp(…)on a hook withevents['beforeFind'],['afterFind']and['afterFind', 'afterUpdate']: refused with a null-guard finding.created_atthe author declares (own label) is judged at the door as at the build (deep-equal findings); the one on anexternalobject is still judged at the door.record.amount > 0(declared nullable) refused at the door with one finding, deep-equal to the build's.packages/runtime/src/domains/meta-flow-hook-injected-column-null-guard.test.ts(new; surface amendment 6884227999), the real door: better-sqlite3 behind the realObjectQL, the realsys_metadata*objects andObjectStackProtocolImplementation, the account registered throughregisterApp, each item saved as a draft in a writable package and published throughpublishMetaItem(6 cases):created_at,updated_at,owner_id,created_bydeclaredrequired: false; a system-context insert stores both timestamps andnullinowner_idandcreated_by.created_at/updated_atconditions publish (rowactive), andos buildreports nothing on the same item.record.owner_id > 'a'gets 422INVALID_METADATAwith oneexpression-invalidissue namingrecord.owner_id; the row staysdraft.beforeInserthook withrecord.created_at > timestamp(…)gets 422INVALID_METADATAwith oneexpression-invalidissue namingrecord.created_at; the row staysdraft.node scripts/ablation-replace.mjs, restore verified blob == HEAD andgit diff HEADempty):df63888d(lint#3324610 cases):finding.operand === finding.field || finding.operand === 'record.' + finding.fieldreplaced by an always-true opaque guard): lint 1 of 10 red, the M2 LIT; a throwaway probe (deleted) split it per site: theafterInserthook and therecord-after-createflow each red.beforeFind/afterFindadded toSTAMPED_ROW_HOOK_EVENTS: lint 1 of 10 red, the S2 LIT.beforeInsertadded toSTAMPED_ROW_HOOK_EVENTS: lint 1 of 10 red, the S1 LIT.efc8003b:STAMPED_COMPARISON_OPERATORS.has(finding.operator)replaced by an always-true opaque guard): lint 1 of 8#33246cases red, the M1 LIT.beforeInsertexception off (includes('beforeInsert')→includes('ABL_33246S1')): lint 1 of 8 red, the S1 LIT; runtime, afterpnpm --filter @objectstack/lint buildandablation-dist-preflightfinding the marker indist/, 1 of 6 red, the S1 LIT. Lint rebuilt after restore;ablation-dist-preflight --absentpasses on all 20 built files with a clean tree.ddd834f5(6#33246lint cases then, 5 runtime cases):main's reading (the stamped skip guarded off by an opaque global): lint 1 of 6 red (the created_at / updated_at LIT); runtime viadist/2 of 5 red (the flow and hook LIT).Measurement
Round 1's probe (deleted, not committed) over the real door at
origin/mainfc283d6d:mainos build(real CLI)validate_expressiongate halfrecord.created_at > timestamp('2025-01-01T00:00:00Z')expression-invalid(nullablecreated_at)record.updated_at > record.created_atrecord.created_at > timestamp(…)beforeInserthookrecord.created_at > timestamp(…)beforeFind/afterFindhookrecord.updated_at > previous.updated_atafterInserthook,record-after-createflowprevious.updated_at)record.owner_id > 'a'owner_id)record.created_at + 1 > 0date arithmeticrunAuthoringRules('build'): no type for an injected column)record.created_at + 1 > 0created_at)record.amount > 0(control)os buildis the real CLI (packages/cli/bin/run.js build) on adefineStackconfig with the same object, flows and hooks.os linton it exits 0. ThebeforeInsert, read-event,previous.and flow-arithmetic build rows arerunAuthoringRules('build'), which judges no injected column.validate_expression's gate half isjudgeAuthoredSiteExpression(siteflow_condition) over the served definition, the call the MCP tool makes; it strips the injected columns, so it stays as it was.created_atandupdated_atandnullinowner_id,created_by,updated_by,owning_business_unit_id,queue(pinned in the runtime file forowner_idandcreated_by).organization_id's injected definition says org scoping stamps it on insert; the door still judges it nullable, as onmain.Acceptance notes
owner_id,created_by,updated_by,owning_business_unit_id,queueandorganization_idnullable, and judgescreated_at/updated_atin abeforeInsertor read-event hook; the build judges no injected column. lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435 owns that verdict; the changeset says so.dyn), the door's has them. Unchanged by this PR.record.created_at + 1 > 0is not type-checked at the door onmainor here (only the bare spelling is); the null guard refuses it, onmainand here (M1).record-before-createbinds abeforeInserthook at the default priority (100), after the stamp (10), so the flow sites are not excepted.record.read in a read-event hook condition (the engine rejects such a read at run time, hook 的condition求不出值时:全局 fail loud —— 抛错并中断该次操作(方案 B 已拍板;Blocked-by #4770) #4775); S2 only keeps this PR's skip off those hooks. Reported to the seat for a card.record.owner_id.nmae) is judged at neither door.Verification
Head
df63888d(round 310f6d63a, round 2ddd834f5, round 1533eb60b; basefc283d6d). Round 4 pushes one commit on the same branch, no rebase, no merge:git diff --stat fc283d6d origin/main(e3f0cfd4at hand-over) over every touched file is empty, andgit merge-treewithorigin/mainis clean. Everything below ran atdf63888d.Package tests
@objectstack/lint: 210/210 files, 8981/8981 tests. Typecheck (tsc --noEmit && check:test-typecheck) exit 0.@objectstack/runtime: the door file 6/6; typecheck (tsc --noEmit && check:test-typecheck) exit 0.@objectstack/metadata-protocol(every save, draft-diagnostics and publish door test, lint read throughdist/rebuilt at this head): 339 files passed, 9 skipped; 22850 tests passed, 43 skipped.Gates (dispatch-gates --commands, 63 lines)
Every line ran with stdin closed and its exit code captured before any pipe. All 63 exited 0 (
check:dual-build-cjs-loadsincluded).dispatch-gates --ran: 63 derived, 63 run, 0 NOT-MEASURED, 0 UNRUN.Dogfood: not run. The title carries no
!andClause-②carries no(narrowing)arm.Generated by Claude Code